package com.example.bookrecommendationjava.controller;

import com.example.bookrecommendationjava.mapper.BookMapper;
import com.example.bookrecommendationjava.mapper.LikeMapper;
import com.example.bookrecommendationjava.mapper.UserMapper;
import com.example.bookrecommendationjava.model.Book;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @BelongsProject: book-recommendation-java
 * @BelongsPackage: com.example.bookrecommendationjava.controller
 * @Author: ZhShy
 * @CreateTime: 2022-03-17 19:51
 * @Description:
 */
@Controller
@RequestMapping("book")
@CrossOrigin(origins = "*", maxAge = 3600)
public class BookController {
    @Autowired
    BookMapper bookMapper;
    @Autowired
    UserMapper userMapper;
    @Autowired
    LikeMapper likeMapper;

    @RequestMapping("bookList")
    @ResponseBody
    public List<Book> bookList(@RequestParam Integer userId){
        return bookMapper.selectAllFromBookByBookIdNotInLikeByUserId(userId);
    }

    @RequestMapping("likeList")
    @ResponseBody
    public List<Book> likeList(@RequestParam Integer userId){
        return bookMapper.selectAllFromBookByBookIdInLikeByUserId(userId);
    }
}
